package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.VlanPartitionFlagHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

/**
 * @author xueyf
 * @Description
 * @Date 2021/5/25 14:52
 */
@Service
@AttrHandler(VlanPartitionFlagHandler.class)
public class VlanPartitionFlagLinkHandler extends AbstractAttrLinkageHandler {
    /**
     * 是否划分VLAN
     */
    private static final String VLAN_PARTITION_FLAG = "2_0000033";

    private static final String VALUE_Y = "1_0000106";

    private static final String VALUE_N = "1_0000107";

    private static final String VLAN_NUMBER = "2_0000145";


    @Override
    public void handle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {
        KiteAttr vlanNumber = kiteInst.getAttr(VLAN_NUMBER);
        if(VLAN_PARTITION_FLAG.equals(kiteAttr.getFieldName())){
            if(VALUE_Y.equals(kiteAttr.getValue())){
                vlanNumber.setIsNull(KeyConsts.IFTRUE_F);
            }else if(VALUE_N.equals(kiteAttr.getValue())){
                vlanNumber.setIsNull(KeyConsts.IFTRUE_T);
            }else {
                vlanNumber.setIsNull(KeyConsts.IFTRUE_T);
            }
        }

    }

    @Override
    public void handleStyle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {

    }
}
